<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浏览器</title>
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>
    <style>
    html,body{
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        background-size:100%;
        background: transparent;
    }
    .bottom-line div{
      float: left;
      line-height: 60px;
      margin-left: 3%;
      font-size: 12px;
      text-align: center;
    }
    .collect{
      background-color:#9D0152;
    }
    .collected{
      background-color:#666666;
    }
    </style>
</head>
<body >
  <div id="app" v-cloak class="bottom-line" style="width:100%;height:100%;background-size:100%;text-align:center;backgroundColor:#ffffff;line-height:50px" >
    <div style="color:#F50101;">可赚：￥<span style="font-size:14px">{{(member_gain_rate*parseInt(goods_info.zkPrice?goods_info.zkPrice*goods_info.tkRate:goods_info.price*goods_info.profit)/100).toFixed(2)}}</span></div>
    <div>优惠券：￥{{parseInt(goods_info.couponAmount?goods_info.couponAmount:goods_info.coupon_amount)}}</div>
    <div><span style="border:2px solid #F50101;height:20px;margin-top:15px;line-height:20px;margin:0 auto;padding:2px 8px;color:#F50101" v-myclick="remind">详细说明</span></div>
    <div style="color:#ffffff;font-size:14px;float:right;padding:0px 20px" class="collect" :class="{'collected':collect==1}" v-cloak v-myclick="collection">{{collect==1?'已添加':'添加'}}{{user.member_type==6?'商品':'收藏'}}</div>
  </div>
</body>
<script src="../../script/vue.js"></script>
<script src="../../script/api.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>
    var vm;
    var goodsselected= [];
    var iscollect =false;
    var collect;
    apiready = function () {

        setBSImg();
        goods_info = api.pageParam.goods_info;
        var data = {
            member_id: getPrefs('member_id'),
            good: JSON.stringify(goods_info),
        };
        var callback = function (ret) {
          collect = ret.content.status;
          gain_rate = ret.content.gain_rate;
          if(collect==1){
            iscollect=true;
          }else{
            iscollect=false;
          }
          user = JSON.parse(getPrefs('user'));
          if(user.member_type==6){
            member_gain_rate = gain_rate.t6_gain_rate_max;
          }else {
            member_gain_rate = gain_rate.t5_gain_rate_max;
          }
          initApp();
        };
        pinet.post(URL.getMycollect, data, callback);
        api.parseTapmode();
    };

    function initApp() {
        vm = new Vue({
            el: '#app',
            data: {
              goods_info:goods_info,
              user:user,
              collect:collect
            },
            methods: {
              collection:function(){
                // this.iscollect = !this.iscollect;
                if (iscollect) {
                  type = 1;
                } else {
                  type = 0;
                }
                var data = {
                    member_id: getPrefs('member_id'),
                    good: JSON.stringify(goods_info),
                    type:type
                };
                var callback = function (ret) {
                  // console.log(JSON.stringify(ret.content));
                  if(ret.errcode==0){
                      if (!iscollect) {
                          vm.collect=1;
                          if(vm.user.member_type==6){
                            msg = '添加成功';
                          }else{
                            msg = '收藏成功';
                          }
                      } else {
                          vm.collect=0;
                          if(vm.user.member_type==6){
                            msg = '取消添加成功';
                          }else{
                            msg = '取消收藏成功';
                          }
                      }
                      iscollect = !iscollect;
                    api.toast({
                        msg: msg,
                        duration: 2000,
                        location: 'bottom'
                    });
                  }
                };
                pinet.post(URL.addVipgoods, data, callback);
              },
              remind:function(){
                  alert('收藏之后，您就可以去我的收藏查看我的商品，处理成功的就可以购买啦');
              }
            },
        })
    }
</script>
</html>
